<?php

namespace app\admin\model;

use think\Model;
use think\model\concern\SoftDelete;

/**
 * Category
 * @controllerUrl 'cart'
 * @property Goods $goods
 * @property GoodsAttr $attr
 */
class Cart extends Model
{
    use SoftDelete;

    // 表名
    protected $name = 'cart';

    // 自动写入时间戳字段
    protected $autoWriteTimestamp = 'int';

    protected $createTime = 'createtime';

    public function goods()
    {
        return $this
            ->hasOne(Goods::class, 'id', 'goods_id')
            ->field('id,category_id,goods_name,slider_images,price,integral,post_price,old_price,vip_price,stock,use_score');
    }

    public function attr()
    {
        return $this
            ->hasOne(GoodsAttr::class, 'id', 'attr_id')
            ->hidden(['id', 'goods_id', 'createtime', 'delete_time']);
    }

}